import request from '@/utils/request'

export default {
  getNowUserInfo(){
      request.get("/user/info").then(res=>{
      store.commit('SETLOGINFO', res.data.userNick)
    })
  },
  getUserList(searchModel) {
    return request({
      url: '/user/list',
      method: 'get',
      params: {
        pageNow: searchModel.pageNow,
        pageSize: searchModel.pageSize,
        username: searchModel.condition,

      }
    });
  },
  deleteUser(user) {
    return request({
      url: '/user',
      method: 'delete',
      params: {
        "id":user.id
      }
    });
  },
  getUserRole(username){
    return request({
      url: '/user/getUserRoles',
      method: 'get',
      params: {
        "username":username
      }
    });
  },

  getCode(number){
    return request({
      url: '/user/code?'+number,
      method: 'get',
      
    });
  },
  updateUser(editUser){
    return request({
      url: '/user/update',
      method: 'post',
      data:{
        id:editUser.id,
        username:editUser.username,
        userNick:editUser.userNick,
        email:editUser.email,
        phone:editUser.phone,
        address:editUser.address,
      }
    });
  },
  updateUserRole(id,roleIdList){
    return request({
      url: '/user/upUserRole',
      method: 'post',
      data:{
        id:id,
        roleIdList:roleIdList
      }
    });
  },
  saveUser(editUser,userRoleList){
    return request({
      url: '/user/add',
      method: 'post',
      data:{
        username:editUser.username,
        password:editUser.password,
        userNick:editUser.userNick,
        email:editUser.email,
        phone:editUser.phone,
        address:editUser.address,
        roleIdList:userRoleList
      }
    });
  },
  removeBatch(val){
    return request({
      url: '/user/batch',
      method: 'post',
      data: val
    });
  },
  

} 